package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/hotel")
public class HotelController {

    @Autowired
    private IHotelService hotelService;

    @PostMapping(value = "/list")
    public PageResult searchByparam(@RequestBody RequestParams params) throws IOException {
        return hotelService.searchByparam(params);
    }

    @PostMapping(value = "/filters")
    public Map<String, List<String>> filter(@RequestBody RequestParams params) throws IOException {
        return hotelService.filters(params);
    }

    @GetMapping(value = "/suggestion")
    public List<String> getSuggestion(@RequestParam("key")String prefix){
        return hotelService.getSuggestion(prefix);
    }
}
